package com.yyysj.system.controller;

import com.yyysj.common.core.domain.Result;
import com.yyysj.common.core.domain.TableDataInfo;
import com.yyysj.system.domain.dto.QuestionAddDTO;
import com.yyysj.system.domain.dto.QuestionEditDTO;
import com.yyysj.system.domain.dto.QuestionQueryDTO;
import com.yyysj.system.domain.vo.QuestionDetailVO;
import com.yyysj.system.service.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
@RequiredArgsConstructor
public class QuestionController {

    private static final Logger log = LoggerFactory.getLogger(QuestionController.class);
    private final IQuestionService questionService;

    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        log.info("list:{}", questionQueryDTO);
        return questionService.list(questionQueryDTO);
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody QuestionAddDTO questionAddDTO) {
        return Result.build(questionService.add(questionAddDTO));
    }

    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId) {
        return questionService.detail(questionId);
    }

    @PutMapping("/edit")
    public Result<?> edit(@RequestBody QuestionEditDTO questionEditDTO) {
        return Result.build(questionService.edit(questionEditDTO));
    }

    @DeleteMapping("/delete")
    public Result<?> delete(Long questionId) {
        return Result.build(questionService.delete(questionId));
    }
}
